package com.hyh.mode.ducksimulator;

import com.hyh.composite.Flock;
import com.hyh.mode.decker.QuackCounter;
import com.hyh.mode.factory.AbstractDuckFactory;
import com.hyh.mode.factory.CountDuckFactory;
import com.hyh.mode.goose.Goose;
import com.hyh.mode.goose.GooseAdapter;
import com.hyh.mode.quack.Quackable;

public class DuckSimulator {

	public static void main(String[] args) {
		new DuckSimulator();
	}
	
	public DuckSimulator() {
		
		AbstractDuckFactory factory = new CountDuckFactory();
		
		Quackable mallardDuck = factory.createMallardDuck();
		Quackable redHeadDuck = factory.createRedHeadDuck();
		Quackable runbberDuck = factory.createRubberDuck();
		Goose goose = new Goose();
		GooseAdapter gooseAdapter = new GooseAdapter(goose);
		Flock flock = new Flock();
		flock.add(mallardDuck);
		flock.add(redHeadDuck);
		flock.add(runbberDuck);
		flock.add(gooseAdapter);
		
		simulate(mallardDuck);
		simulate(redHeadDuck);
		simulate(runbberDuck);
		simulate(gooseAdapter);
		simulate(flock);
		System.out.println(QuackCounter.getCount());
	}
	
	void simulate(Quackable duck){
		duck.quack();
	}
}
